package com.cqupt.tomwang.custom.coustomView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by admin on 16/3/27.
 */
public class DrawView extends View {
    private Paint p = new Paint();
    private float cx = 0;
    private float cy = 0;
    private float r = 10;
    public DrawView(Context context) {
        super(context);
    }

    public DrawView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        p.setColor(Color.BLUE);
        canvas.drawCircle(cx, cy, r, p);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        cx = event.getX();
        cy = event.getY();
        //通知当前组建重绘自己
        invalidate();
        return true;
    }
}
